package com.itcast.job;

import com.itcast.constant.RedisConstant;
import com.itcast.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;

public class job {
        @Autowired
        private JedisPool jedisPool;
    public void clearImg(){
        Set<String> sdiff = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        if (sdiff!=null){
            for (String ImgName : sdiff) {
                QiniuUtils.deleteFileFromQiniu(ImgName);
                jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES,ImgName);
                System.out.println(ImgName);
            }
        }
    }
}
